package com.jwgf.faultnavigation;

import android.view.View;

import com.jwgf.adapter.ItemViewDelegate;
import com.jwgf.adapter.RecyclerViewHolder;
import com.jwgf.smarowindingmachine_unity.R;

import org.greenrobot.eventbus.EventBus;

public class FaultNavigationButtonDelegate implements ItemViewDelegate {
    @Override
    public int getItemViewLayoutId() {
        return R.layout.navigation_button;
    }

    @Override
    public boolean isForViewType(Object item, int position) {
        return item instanceof FaultNavigationAttr;
    }

    @Override
    public void bindView(RecyclerViewHolder holder, Object o, int position) {
        final FaultNavigationAttr attr = (FaultNavigationAttr) o;
        holder.setText(R.id.btn, attr.name);
        holder.setOnClickListener(R.id.btn, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(attr);
            }
        });
    }
}
